﻿using Autofac;
using Autofac.Extras.DynamicProxy;
using System.Reflection;

namespace Lanbt.Core.Web.ServiceExtent
{
    public class AutofacSetup : Autofac.Module
    {

        protected override void Load(ContainerBuilder builder)
        {
            #region Repository And Service DI

            var repository = Assembly.Load("Lanbt.Core.Repository");
            var service = Assembly.Load("Lanbt.Core.Service");

            builder.RegisterAssemblyTypes(repository)
                .SingleInstance()
                .AsImplementedInterfaces()
                .EnableInterfaceInterceptors();

            builder.RegisterAssemblyTypes(service)
                .SingleInstance()
                .AsImplementedInterfaces().EnableInterfaceInterceptors();
            base.Load(builder);

            #endregion
        }

    }
}
